var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {

  // test mysql
  var mysql = require('mysql');
  var conn = mysql.createConnection({
      host: '192.168.7.3',
      user: 'root',
      password: 'sleeping',
      database:'enhome',
      port: 3306
  });
  conn.connect();
  conn.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
      if (err) throw err;
      console.log('The solution is: ', rows[0].solution);
  });
  conn.end();
  //end test


  res.render('index', { title: '项目名称' });
});

/* GET home page. */
router.get('/index', function(req, res, next) {
  res.render('index', { title: '项目名称' });
});
/* GET home page. */
router.get('/login', function(req, res, next) {
  res.render('login', { title: '登陆系统' });
});

module.exports = router;
